package com.app.manage.moudles.confs.service.impl;

import com.app.manage.moudles.confs.entity.TGroup;
import com.app.manage.moudles.confs.entity.TGroupRelation;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.app.manage.moudles.confs.dao.TVariDao;
import com.app.manage.moudles.confs.entity.TVari;
import com.app.manage.moudles.confs.service.TVariService;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * (TVari)表服务实现类
 *
 * @author makejava
 * @since 2025-05-16 11:15:30
 */
@Service("tVariService")
public class TVariServiceImpl extends ServiceImpl<TVariDao, TVari> implements TVariService {

    @Override
    public String saveData(TVari tVari) {
        long count = count(new LambdaQueryWrapper<TVari>()
                .ne(tVari.getId() != null,  TVari::getId,tVari.getId())
                .eq(TVari::getVariKey,tVari.getVariKey())
                .eq(TVari::getVariType,tVari.getVariType())
                .last(" limit 1")
        );
        if(count > 0){
            return "当前变量已经存在！";
        }
        if(tVari.getId() == null){
            tVari.setCreateTime(new Date());
            save(tVari);
        }else {
            tVari.setCreateTime(new Date());
            updateById(tVari);
        }
        return null;
    }
}

